<?php
require_once dirname(__FILE__) . '/includes/common.inc.php';
require_once dirname(__FILE__) . "/database/$database/database.inc.php";

header('Content-Type: text/plain');

global $myManager;

try {
  $hostname = HOST_NAME;
  $username = USER_NAME1;
  $password = PASSWORD1;
  $dbname = DATABASE_NAME1;
  $myPdo = new PDO ('mysql:host=' . $hostname, $username, $password);
  $myPdo->exec('USE ' . $dbname);
  $myPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

} catch (PDOException $e) {
  echo $e->getMessage ();
}

try {
  $sql = "SELECT DISTINCT e.e_oid AS id, e.method, e.note, e.status FROM ns_Expense AS e WHERE e.method = '' AND e.note LIKE '%customerNo:%'";
  $stmt = $myPdo->prepare($sql);
  $stmt->execute();
  
  $i = 0; $res = array();
  while ($i < $stmt->rowCount()) {
    $tmp = $stmt->fetch(PDO::FETCH_OBJ);
    $myPdo->exec("delete from ns_Expense WHERE e_oid = $tmp->id");
    $i++;
  }
  
  MiscUtils::dump($res);
} catch (PDOException $e) {
  echo $e->getMessage();
}
?>